$(function(){
	//加载我的列表
	loadPrescription();
	mui.previewImage();
});
function loadPrescription(){
	var param= {"id": utilModule.getQueryString("orderid")};
	prescriptionModule.queryPrescriptionDetails(param,showPrescription);
}
function showPrescription(data){
		 var showhtml="";
		 console.log(utilModule.getQueryString("id"));
		 if(data==undefined){
			  return;
		 }
	    var json = eval(data); 
 		if(json){
 			showhtml+='<div class="prescription-sheetBox">';
			showhtml+='<div class="title">我的处方单 <span class="diagnosis">'+json.diagnosis+'</span></div>';
			showhtml+='<div class="main font">';
			showhtml+='<table cellpadding="0" cellspacing="0">';
			showhtml+=	'<thead><tr><td>药品</td><td style="width: 1rem;">数量</td><td style="width: 1rem;">用量</td><td style="width: 1rem;">频次</td></tr></thead>';
			showhtml+=	'<tbody>';
				if(json.prescriptionDetailList){
					for(var j=0;j<json.prescriptionDetailList.length;j++){
					
					var list=json.prescriptionDetailList[j];
					showhtml+='<tr><td>'+list.name+'</td>';
					showhtml+='<td>'+list.count+'盒</td>';
					if(list.usagemethod!=""){
						var strs=list.usagemethod.split("-"); //字符分割
						showhtml+='<td>'+strs[1]+'</td>';
						showhtml+='<td>'+strs[0]+'</td>';
					}else{
						showhtml+='<td>每次500g</td>';
						showhtml+='<td>一日三次</td>';
					}
					showhtml+='</tr>';
					}
				}else{
					$("#prescription-content").hide();
					mui.alert("此处方单已被删除",'提示');	
				}
 			showhtml+='</tbody></table>';
			var $told = json.told;
			if(utilModule.checkUndefined($told)!="") {
				showhtml+='<div class="entrust">医生嘱托:'+$told+'</div>';
				
			}
			showhtml+='<div class="time">';
			showhtml+=	json.createtime;
			showhtml+='<span><img style="width:1.5rem;" src="'+json.autograph+'"    data-preview-src=""   data-preview-group="1" /></span>';
			showhtml+='<span> 医师签名:</span>';
			showhtml+='<font></font>';
			showhtml+='</span></div></div></div>';
			showhtml+='<div class="prescription-sheetOperation">';
			showhtml+='<button id="adress" class="adress" href="../onlineContinuation/drug-delivery.html?id='+json.id+'">一键寻药</button></div>';
	 		$("#prescription-content").html(showhtml);	
	    	$("#adress").on('click',function(){
	   			 location.href = $(this).attr("href");
	   		});
 		}else{
 			mui.alert("此处方单不存在",'提示');
 		}
 
	};